package com.yz.springtest.resource;

import java.io.IOException;

import org.junit.After;
import org.junit.AfterClass;
import org.junit.Assert;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.springframework.core.io.Resource;
import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
import org.springframework.core.io.support.ResourcePatternResolver;

public class FileSourceExampleTest {

	@BeforeClass
	public static void setUpBeforeClass() throws Exception {
	}

	@AfterClass
	public static void tearDownAfterClass() throws Exception {
	}

	@Before
	public void setUp() throws Exception {
	}

	@After
	public void tearDown() throws Exception {
	}

	@Test
	public void test() throws IOException {
		 
		//加载所有类包com.yz(及子孙包)下以.xml文件
		ResourcePatternResolver resolver = new PathMatchingResourcePatternResolver();
		//** 匹配多层路径
		Resource[] resources = resolver.getResources("classpath*:**/*.xml");
		Assert.assertNotNull(resources);
		for (Resource resource : resources) {
			System.out.println(resource);
		}
	}

}
